/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.mcx.modules.generation.rest;

import com.mcx.modules.generation.domain.Rechargelog;
import com.mcx.modules.generation.service.RechargelogService;
import com.mcx.modules.generation.service.dto.RechargelogQueryCriteria;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

/**
* @website https://el-admin.vip
* @author mcx
* @date 2022-04-30
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "rechargelog管理")
@RequestMapping("/api/rechargelog")
public class RechargelogController {

    private final RechargelogService rechargelogService;

    @GetMapping
    public ResponseEntity<Object> queryRechargelog(RechargelogQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(rechargelogService.queryAll(criteria,pageable),HttpStatus.OK);
    }

    @PostMapping
    public ResponseEntity<Object> createRechargelog(@Validated @RequestBody Rechargelog resources){
        return new ResponseEntity<>(rechargelogService.create(resources),HttpStatus.CREATED);
    }

    @PutMapping
    public ResponseEntity<Object> updateRechargelog(@Validated @RequestBody Rechargelog resources){
        rechargelogService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    public ResponseEntity<Object> deleteRechargelog(@RequestBody Integer[] ids) {
        rechargelogService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}